//
//  NSDictionary+Extension.m
//  gzdai
//
//  Created by LaughingZhong on 15/7/22.
//  Copyright © 2015年 gzdai. All rights reserved.
//

#import "NSDictionary+Extension.h"

@implementation NSDictionary (Extension)

+ (NSDictionary *)getDictionaryFromDictionary:(NSDictionary *)dic withKey:(NSString *)key
{
    if (CHECK_DICTIONARY(dic, key)) {
        if ([[dic objectForKey:key] isKindOfClass:[NSDictionary class]]) {
            return [dic objectForKey:key];
        }
    }
    return nil;
}

+ (NSString *)getStringFromDictionary:(NSDictionary *)dic withKey:(NSString *)key
{
    if (CHECK_DICTIONARY(dic, key)) {
        if ([[dic objectForKey:key] isKindOfClass:[NSString class]]) {
            return [dic objectForKey:key];
        }
    }
    return @"";
}
+ (NSArray *)getArrayFromDictionary:(NSDictionary *)dic withKey:(NSString *)key
{
    if (CHECK_DICTIONARY(dic, key)) {
        if ([[dic objectForKey:key] isKindOfClass:[NSArray class]]) {
            return [dic objectForKey:key];
        }
    }
    return nil;
}
+ (float)getFloatFromDictionary:(NSDictionary *)dic withKey:(NSString *)key
{
    if (CHECK_DICTIONARY(dic, key)) {
        if ([[dic objectForKey:key] isKindOfClass:[NSNumber class]]) {
            return [[dic objectForKey:key] floatValue];
        }
    }
    return 0.0;
}
+ (NSNumber *)getNumberFromDictionary:(NSDictionary *)dic withKey:(NSString *)key
{
    if (CHECK_DICTIONARY(dic, key)) {
        if ([[dic objectForKey:key] isKindOfClass:[NSNumber class]]) {
            return [dic objectForKey:key];
        }
    }
    return nil;
}

@end
